<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('物料信息管理列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">

<div class="ui-layout-center">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="json" name="json">

                    <div class="select-list">
                        <ul>
                            <li>
                                <label>物料编号：</label>
                                <input type="text" name="code"/>
                            </li>
                            <li>
                                <label>物料名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="type" th:with="type=${@dict.getType('wl_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>


            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wms:materialInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wms:materialInfo:remove')}]];
        var typeDatas = [[${@dict.getType('wl_type')}]];
        var unitDatas = [[${@dict.getType('wl_unit')}]];
        var statusDatas = [[${@dict.getType('sys_job_status')}]];
        var prefix = ctx + "wms/materialInfo";

        $(function() {
            $(function() {
                queryUserList();
            });


        });
        function queryUserList() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                onCheck: onCheck,
                onUncheck: onUncheck,
                onCheckAll: onCheckAll,
                onUncheckAll: onUncheckAll,
                modalName: "物料信息管理",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '用户id',
                        visible: false
                    },{
                        field: 'deptId',
                        title: '仓库id',
                        visible: false
                    },{
                        field: 'parentName',
                        title: '仓库'
                    },
                    {
                        field: 'code',
                        title: '物料编号'
                    },
                    {
                        field: 'name',
                        title: '物料名称'
                    },
                    {
                        field: 'model',
                        title: '规格型号'
                    },
                    {
                        field: 'type',
                        title: '类型',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(typeDatas, value);
                        }
                    },
                    {
                        field: 'unit',
                        title: '单位',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(unitDatas, value);
                        }
                    },
                    {
                        field: 'total',
                        title: '库存总数'
                    }]
            };
            $.table.init(options);
        }
        var arr = new Array();
        function onCheck(row, $element){
            arr.push(row);
            $("#json").val(JSON.stringify(arr).toString());
        }

        function onUncheck(row, $element){
            ar.remove(row)
            $("#json").val(JSON.stringify(arr).toString());
        }

        function onCheckAll(rowsAfter, rowsBefore){
            arr = new Array();
            var rows = $.map(rowsAfter, function(row) {
                arr.push(row);
            });

            $("#json").val(JSON.stringify(arr).toString());
        }

        function onUncheckAll(rowsAfter, rowsBefore){
            arr = new Array();
            $("#json").val("");
        }
        Array.prototype.remove=function (val) {
            var index = this.indexOf(val);
            if(index >-1){
                this.splice(index,1)
            }
        }
    </script>
</body>
</html>